<?php 
namespace app\index\model;
use think\Db;

/**
* 
*/
class Loginaction
{
	
	public function register($phone,$pass)
	{
		$preg = "/^[1][34578][0-9]{9}$/";
		if(preg_match($preg,$phone)){
			$data = db('user')->where('phone',$phone)->find();
			if (md5($pass) == $data['pass']) {
				$user = db('information')->where('userid',$data['id'])->find();
				if ($user['status'] == 1) {
					$row = ['id'=>$data['id'],'name'=>$user['name'],'img'=>$user['img'],'type'=>$user['type']];
					session('user',$row);
					return 1;
				}else{
					return 2;
				}
				
			}else{
				return 0;
			}
		}else{
		 	return 0;
		}
	}
}